package response

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type Result struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data,omitempty"`
}

func JSON(c *gin.Context, code int, msg string, data interface{}) {
	c.JSON(http.StatusOK, Result{code, msg, data})
}

func Success(c *gin.Context, data interface{}) {
	JSON(c, CodeSuccess, "success", data)
}

func Fail(c *gin.Context, code int, msg string) {
	JSON(c, code, msg, nil)
}
